home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
007
/
qbbugs.arc
/
QUIRKS.TXT
Wrap
Text File
|
1987-12-23
|
22KB
|
454 lines
New items for this release 12/23/87:
Part 1 - TYPE..END TYPE
Part 2 - Long Integers
Part 3 - Sample program #2
-------------------------------------------------------------------------
This file contains information about bugs, quirks, and general points
of interest to programmers working with compiled BASIC. It is divided
into three parts:
Part 1 - Description of bugs, quirks and errors
Part 2 - General points of interest
Part 3 - Sample programs
If you want to find one of the above quickly, use your text editor to
search for the text shown above. i.e., Search for "Part 1 -".
This file was compiled by Mark Novisoff of MicroHelp, Inc. Much of the
information was contributed by members of MicroHelp's BASIC Users Group.
If you have additional information that should be added, please send it
to:
Mark Novisoff
MicroHelp, Inc.
2220 Carlyle Drive
Marietta GA 30062
(404) 973-9272
Compuserve ID 73047,3706 in MSSYS (Microsoft Systems Forum)
Part 1 - Description of bugs, quirks and errors
Command/Error Compilers Description
-------------- --------------- --------------------------------------------
CALL (asm) QB 4 Effective with QB 4, assembly
language subroutines must preserve
the SI and DI registers and make
sure the direction flag is cleared
before returning to BASIC.
CALL INIT QB 2-3 Do not name a precompiled subprogram "INIT".
If you do, the compiler will go into never-
never land when your user library is loaded.
CALL vs GOSUB All If you have many calls to the same
asm routine or subprogram, you'll
use less memory if you set
variables and GOSUB to a routine
that performs the CALL instead of
having the CALL "in line". CALL is
much faster using variables than
using "literals".
CALLS QB 4 When CALLS (note the "S") is used and you
compile with "/D" (debug), the segment of
of a string element descriptor does not get
passed on the stack. In other words, if you
have an assembly language subroutine that
uses CALLS, you should not compile with "/d".
CHAIN QB 4 Unreliable when using DOS 2.x.
CIRCLE QB 4 The start and end angles must be
LESS than 2*pi. Previously they could
be less than or equal to.
CLEAR,,Size QB 3,4 If you receive an out of stack
space message. The stack size is
not reset between CHAIN'ing but if
you CHAIN back to your original
program, be sure to skip the CLEAR
instruction.
COMMON and QB 2-4 All statements that use COMMON or variations
COMMON SHARED thereon with CHAIN must use parameter lists
that match exactly. Best done with $Include.
COMMON with TYPE
QB 4 The TYPE statement must appear before
the COMMON statement and must appear in
all programs that use it. The COMMON
statement must contain "AS". See sample
program #1 at the end of this file.
Compile to EXE QB 4 QB issues an unusual LINK command in the
form of:
LINK Prog+YourLib.Lib;
This causes LINK to bring the entire
library into your program! The solution is
to exit QB, and run BC and LINK yourself.
CONST QB 4 Must be included in all program modules
that use the constant. Place in the file
at the top, rather than inside SUB's.
DATA QB 4 When a DATA statement is encountered inside
a SUB...END SUB structure, QB moves it
into the "mainline" portion of the code when
you are in the environment.
DEF FN All Functions are local to the module
in which the DEF FN appears. Use
QB 4's FUNCTION..END FUNCTION for
global functions.
DIM QB 4 Static numeric arrays are stored on the
"heap" when you are inside the QB 4
environment. BC programs store them in the
default DS.
DIM (TYPE) QB 4 See sample program #1 for dimensioning
arrays of TYPE'd variables.
Division All Using integer division "\" when an
integer result is desired is much
faster than normal division "/".
DRAW QB 2-4 Does not respect the boundaries designated
by WINDOW.
FRE(-1) QB 4 If a Quick Library is loaded, this value
may return incorrectly. QB 4 seems to
forget that the library is loaded and
thinks that the space is available. But,
QB 4 won't let you use the space for
dynamic arrays.
FRE("") QB 4 Using BRUN gives approximately 4K more
than BCOM.
FUNCTION QB 4 Provides global functions for all
modules in a program. All that is
needed is a DECLARE statement in
any module that needs to use the
function. In addition, this type
of function can be recursive. See DEF FN.
FUNCTION QB 4 Cannot be used in $Include files.
IF..THEN..ELSE QB 3 More than two nestings for ELSE on a single
line will not compiler properly.
HEX$ QB 4 Be careful when using with non-integer
values. For example, the output from
the two lines shown is "FFFF8002".
E&=&H8002
PRINT HEX$(E&)
LINK All Use the /EXEPACK switch to condense the
file. Can be used on any program except
programs that are CHAIN'ed to using
all compilers except QB 4. All QB 4
programs can use this switch. Syntax:
LINK /EXE Progname (etc.)
LINK QB 4 When building a Quick Library, be sure
to specify BQLB40 in the library field. Example:
LINK /QU ObjMods,Lib,,BQLB40;
LOAD QB 4 If you receive an "out of memory"
error, try breaking your program
into logical pieces (using
subprograms). Then use COMMON
SHARED for all variables that you
need in the entire program. The
exact same COMMON SHARED
declaration must appear in all the
modules in the program that need
access to the variables.
LOAD QB 4 If you download a QB 4 program in "fast load"
format, many modem transfer protocols
pad the file out using a number of
CHR$(0)'s. This will cause QB 4 to
crash when you attempt to load the program.
Use DEBUG to view the file, then write
the program to disk after changing the
CX register to shorten the length of the
file so that the trailing CHR$(0)'s are
not included. The other solution is to
download this type of file using an ARC
program that restores the original length
of the file.
ON ERROR QB 2-4 Error handler routines must be located
outside SUB...END SUB structures. You
can RESUME to a line number/label that
is outside SUB...END SUB structures
(using /E) or to code inside the sub
using plain RESUME or RESUME
NEXT (/X). Much better is to $Include
subroutines that perform error trapping
instead of having them in subprograms.
This allows the use of RESUME line number/
label and avoids the /X.
OPEN All With Novell NetWare, using OPEN on a file that
does not exist does not always create the file.
Novell has acknowledged the problem but no
solution is available as of 12/19/87.
Overflow All BASIC uses integer types for all
calculations and processes the
right side of the equal sign
before the left side. To force
BASIC to use a different numeric
type, place a type identifier on
the right of the equal sign.
Example: A=Peek(2)+256!*Peek(3)
RESUME All If you always use RESUME
<linenumber> or RESUME <label> you
can use the "/e" switch instead of
"/x". Makes programs smaller!
This is not practical for
subprograms, so error trapping is
better handled in mainline code.
See ON ERROR.
RESUME QB 4 If you compile to an EXE from
inside the environment, a "/X" is
generated by QB even though it's
not needed. Be sure to recompile
with "/E" outside of the
environment if your program
doesn't need "/X".
SADD QB 4 When using SADD-188 for Btrieve,
be sure to make this calculation
EACH TIME you are going to CALL
Btrieve. This is because QB 4 can
move the FIELD'ed strings around
in memory.
SAVE QB 4 If you edit a new program and save it,
QB defaults to "fast load" format. The
file cannot be handled by a text editor.
Fix by using "save as".
SELECT CASE QB 4 Doesn't allow periods in variable names that
are "plain" variables. If using a TYPE'd
record element (which does indeed use periods),
QB 4 will accept that with no problem.
SIGNAL QB 4 Keyword reserved for future use.
SLEEP QB 4 Keyword reserved for future use.
SOUND QB 3/87 Generates error 6 in all forms when the
emulator is used on non-87 machines.
STATIC QB 4 When used with a subprogram, makes
the subprogram faster, since local
variables are not initialized on
each call.
String Space QB 4 Drops you out to DOS without saving
Corrupt your program. The solution is to save
often!
STRING$ All A$=String$(5,65) takes less code than
A$=String$(5,"A") and both are smaller
than A$="AAAAA".
SUB...END SUB QB 4 Cannot be used in $Include files. Cannot
have the same name as a variable (regardless
of the variable type).
TYPE..END TYPE QB 4 There has been an unverified problem reported
in QB when the record length is an odd number.
A "FAR HEAP CORRUPT" error is generated.
The problem reportedly occurs when the record
length is an odd number of bytes. It does not
seem to appear in BC, only QB. If you have
an unusual, otherwise unexplained problem,
try changing the record length to an even number.
TYPE..END TYPE
(with COMMON) QB 4 See COMMON (with TYPE) and sample program #1.
VAL QB 4 Generates an error (rather than value of 0)
when "%" is the first character in the string.
WINDOW QB 2-4 Does not affect DRAW statements.
----------------------------------------------------------------------------
Part 2 - General points of interest
----------------------------------------------------------------------------
Long integers with QB 4
When you have a long integer array with two dimensions, BC does not handle
the zeroth elements correctly, but QB works with it OK. The fix is not to
use the zeroth elements.
Secondly, if you dimension the same two-dimensional array using a variable
name instead of a numeric constant, BC cannot handle your array at all! The
fix is to use only constant numbers in dimensioning the array. Another fix
that DOES work with dynamic arrays, is to use the /R switch when compiling.
----------------------------------------------------------------------------
More on long integers
If you pass a long integer array to a subprogram, QB will work OK, but
BC does not. See Sample Program #2.
----------------------------------------------------------------------------
LIB environment variable
If you set the LIB environment variable, you will find that QB, BC, BUILDLIB
and LINK will all search the specified path whenever a User Lib, Quick Lib or
LINK lib is needed. The syntax is similar to the DOS Path syntax:
SET LIB=C:\Libs;C:\DOS;C:\QB
----------------------------------------------------------------------------
Undocumented switches in QuickBASIC 3
QB ProgramName/F compiles the specified program to an EXE file without
starting up the QB editor.
QB ProgramName/Z tells QB to load and execute ProgramName and exit to DOS
when the program ends.
----------------------------------------------------------------------------
Response files
BUILDLIB and LINK both accept input from response files. This is exactly the
same as redirection of input, but the programs will continue running when
the end of the file is reached prematurely. Example:
Response file contains:
Prog1+Prog2+Prog3+
Prog4+Prog5+Prog6 Rem Don't include ANY additional blank lines
Buildlib batch file contains:
Buildlib @Response.Fil,MyLib.Exe;
Buildlib will take its input from the response file because the "@" sign
tells it to!
----------------------------------------------------------------------------
BUILDLIB and "too many segments" error
Where "nnnn" is a number from 1 to 1024, use:
BUILDLIB /SEG:nnnn
That increases (or decreases) the number of allowable segments. Default=255.
----------------------------------------------------------------------------
Patching QB 4 menu and help colors.
This color table in this file was uploaded by Dave Engfer to the
MicroHelp Basic Users Group BBS.
If you don't like the colors that QB 4.0 uses, you can patch it to show
the colors you want. In order to effect your patches, do the following:
Make a backup copy of QB.EXE.
REN QB.EXE QB <Enter>
DEBUG QB <Enter>
R <Enter>
At this point, debug will show you the current register settings and
the current instruction. Something like this:
-r
AX=0000 BX=0003 CX=82A0 etc.
DS=xxxx ES=xxxx SS=xxxx etc.
xxxx:0100 RD DEC BP
The "xxxx" is the current code segment. On my machine, the value is 2A28.
The color table that QB uses is located near the end of the QB program,
specifically 3 full segments higher than "xxxx". That means you will
need to add 3000 hex to the number of the segment shown. In my case,
I would patch segment 5A28. Note that adding 3 to the first of the four
hex numbers does the trick.
Now, with the higher segment address in mind, display the existing color
table. Remember, the segment on your machine is most likely different
from mine, but the offset "5B6F" should be the same. On my system:
d 5A28:5B6F <Enter>
gives the following table (on my system, "xxxx" is 5A28):
xxxx:5B60 34
xxxx:5B70 30 4F 34 30 38 4F 47 34-38 70 71 74 07 47 0A 30
xxxx:5B80 3F 17 4A 00 07 70 70 0F-7F 70 78 0F 07 7F 70 70 etc.
Below you'll find a table of the colors and what Dave thinks they represent.
Note that some are marked "unknown". Dave suspects they may be related to
rodents.
You can change your copy of QB to display the various colors by changing
the values in the table. The formula for determining color is the same as
in Mach 2: Attribute=Background*16+Foreground.
As an example, suppose you want to change the "top line highlight" to
red on green (XMAS is only a month away!). The color attribute we want
(in HEX for debug) is 2*16+4 or 36 decimal or 24 HEX.
So, to patch that color:
-e xxxx:5B71 24 <Enter>
-w <Enter>
-q <Enter>
REN QB QB.EXE
Now, when you hold the Alt key (without pressing anything else), "File"
appears in red on green.
Original Color Addr Byte Effect
---------------------------------------------------------------------
Red on Cyan 5B6F 34 The outline for the pulldown boxes
Black on Cyan 5B70 30 The Color for the top line
Bright White on Red 5B71 4F Top line Highlight (e.i. press 'Atl'
and the option will highlight)
Red on Cyan 5B72 34 Top line first letter highlight
Black on Cyan 5B73 30 *Pulldown box text and background - 1
Bright Black on Cyan 5B74 38 *Pulldown box text and background - 2
Bright White on Red 5B75 4F *Pulldown box highlight line - 1
White on Red 5B76 47 *Pulldown box highlight line - 2
Red on Cyan 5B77 34 *Pulldown box first letters - 1
Bright Black on Cyan 5B78 38 *Pulldown box first letters - 2
Black on White 5B79 70 Frame around the Help box- Shft F1
Blue on white 5B7A 71 Help box selection area- Shft F1
Red on White 5B7B 74 Help box first letter highlight- F1
5B7C 07 Unknown
5B7D 47 Unknown
5B7E 0A Unknown
Black on Cyan 5B7F 30 Bottom line prompt text
Bright White on Cyan 5B80 3F Microsoft Copyright Notice
Notes-
* - Microsoft uses two different color bytes for the pulldown boxes.
1 - This byte seems to be used for options with a highlight letter.
2 - This byte seens to be used for options without a highlight letter.
----------------------------------------------------------------------------
Part 3 - Sample programs
----------------------------------------------------------------------------
Sample program #1. How to use COMMON with TYPE'd variables.
' Prog1.bas
TYPE Namerec
LastName AS STRING * 20
FirstName AS STRING *15
END TYPE
COMMON Filename() AS Namerec
DIM Filename(5) AS Namerec
Filename(1).LastName="Novisoff"
Filename(1).FirstName="Mark"
CHAIN "Prog2"
' Prog2.bas
TYPE Namerec
LastName AS STRING * 20
FirstName AS STRING * 15
END TYPE
COMMON Filename() AS Namerec
PRINT Filename(1).LastName, Filename(1).FirstName
----------------------------------------------------------------------------
Sample program #2. Demonstrates problem with long integers in subprograms.
DECLARE SUB TestLong (LongArray&())
'Demonstration to show difference between return values of long int
'
'Returns desired value if compiled in the env but not if compiled by BC
'
'This fault only appears if the code is in a subprogram and compiled with BC
REM $Dynamic
DIM LongArray&(10)
DIM MainArray%(10)
CLS
LongArray&(1) = 100
MainArray%(1) = 10
FOR x% = 1 TO 2
LongArray&(1) = MainArray%(1) + LongArray&(1)
NEXT
PRINT "TestLong should = 120"
PRINT "Long Array from MAIN = "; LongArray&(1)
PRINT : PRINT "Same code in a subprogram"
PRINT
CALL TestLong(LongArray&())
PRINT "TestLong should return 120"
PRINT "Long Array from TestLong sub = "; LongArray&(1)
SUB TestLong (LongArray&())
DIM IntArray%(10)
LongArray&(1) = 100
IntArray%(1) = 10
FOR x% = 1 TO 2
LongArray&(1) = IntArray%(1) + LongArray&(1)
NEXT
END SUB